package com.ylesb.ioc.shoucmd;
/**
 * @title: JavaConfig
 * @projectName springdemo
 * @description: TODO
 * @author White
 * @site : [www.ylesb.com]
 * @date 2022/7/710:21
 */

import com.ylesb.ioc.javaconfig.SayHello;
import org.springframework.context.annotation.*;

/**
 * @className    : JavaConfig
 * @description  : [javaconfig 类似于applicationContext.xml]
 * @author       : [XuGuangchao]
 * @site         : [www.ylesb.com]
 * @version      : [v1.0]
 * @createTime   : [2022/7/7 10:21]
 * @updateUser   : [XuGuangchao]
 * @updateTime   : [2022/7/7 10:21]
 * @updateRemark : [描述说明本次修改内容] 
 */
@Configuration
public class JavaConfig {
    @Bean("cmd")
    @Conditional(WindCondition.class)
    ShowCmd winCmd()
    {
       return new WindCmd();
    }
    @Bean("cmd")
    @Conditional(LinuxCondition.class)
    ShowCmd LinuxCmd()
    {
        return new LinuxCmd();
    }

    @Bean()
    @Profile("dev")
    DataSource devDS() {
        DataSource ds = new DataSource();
        ds.setUrl("devUrl");
        ds.setUsername("devroot");
        ds.setPassword("dev");
        return ds;
    }
    @Bean()
    @Profile("prod")
    DataSource prodDS() {
        DataSource ds = new DataSource();
        ds.setUrl("prodUrl");
        ds.setUsername("prodroot");
        ds.setPassword("prod");
        return ds;
    }

}
